package com.gitee.taotaojs.mybootsuper.mapper;

import org.apache.ibatis.mapping.MappedStatement;
import tk.mybatis.mapper.mapperhelper.MapperHelper;
import tk.mybatis.mapper.mapperhelper.MapperTemplate;

/**
 * 基本通用Mapper的SQL方法
 * @author TaoTaojs
 * @date 2020年03月20日15:49:46
 * <p>Description</p>
 * 基本通用Mapper的SQL方法
 * 关联类:
 * 参考链接：
 */
public class MyBasicProvider extends MapperTemplate {

    /** 魔法值提取，统一使用此字符串 */
    public static final String SQLSTR = "${sql}";

    public MyBasicProvider(Class<?> mapperClass, MapperHelper mapperHelper) {
        super(mapperClass, mapperHelper);
    }

    @SuppressWarnings("checkstyle:MissingJavadocMethod")
    public String findBySql(MappedStatement ms){
        return bySqlMain(ms);
    }

    @SuppressWarnings("checkstyle:MissingJavadocMethod")
    public String updateBySql(MappedStatement ms) {
        return bySqlMain(ms);
    }

    @SuppressWarnings("checkstyle:MissingJavadocMethod")
    public String insertBySql(MappedStatement ms) {
        return bySqlMain(ms);
    }

    @SuppressWarnings("checkstyle:MissingJavadocMethod")
    public String deleteBySql(MappedStatement ms) {
        return bySqlMain(ms);
    }

    @SuppressWarnings("checkstyle:MissingJavadocMethod")
    public String bySqlMain(MappedStatement ms){
        Class<?> entityClass = getEntityClass(ms);
        //修改返回值类型为实体类型
        setResultType(ms, entityClass);
        return SQLSTR;
    }

}
